#ifndef UTILITIES_H
#define UTILITIES_H

#include <time.h>
#include <sys/times.h>

struct Timer
{
    struct timeval td_start;
    struct timeval td_end;
};

void startTimer( struct Timer* timer ) 
{
	gettimeofday( &(timer->td_start), NULL );
}

void stopTimer( struct Timer* timer ) 
{
	gettimeofday( &(timer->td_end), NULL );
}

double getTime_ms( struct Timer* timer )
{
	double elapsed = 1e6 * ( timer->td_end.tv_sec - timer->td_start.tv_sec );
	elapsed += ( timer->td_end.tv_usec - timer->td_start.tv_usec );

	return elapsed / 1e3;
}

#endif